package com.example.studentmanager.service.impl;

import com.example.studentmanager.model.Course;
import com.example.studentmanager.model.vo.CourseVo;
import com.example.studentmanager.service.ChooseCourse;
import com.example.studentmanager.utils.BaseDao;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 主要利用提供者、消费者模型来实现选课服务
 */


/*
@Component
@Service
public class ChooseCourseImpl implements ChooseCourse {



    SqlSession sqlSession= new BaseDao().getSession();
    List<Course> courses;
    Course course;





    //这里是用到多线程模式，而且用的是生产者和消费者模型，那么就要去设定相应的生产方法和消费方法，这里就是设定相关的发给发

   /* public synchronized void addandUpdateCourse()  {

        if(getCourseNum()>0){
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }else{
            System.out.println("添加课程+1");
            this.notify();
        }



    }

    public synchronized void getCourse()  {
        if(getCourseNum()==0){
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }else{
            System.out.println("选课完成-1");
            this.notify();
        }
    }
*/
/*
    @Override
    public  int getAllCourse() {
        int courseNum=0;
        if(this.courses!=null) {
           courseNum = this.courses.size();
        }
        return courseNum;
    }

    @Override
    public synchronized void   setCourse(List<CourseVo> courses1) {
        if(getAllCourse()>0){
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }else{
            //courses=new CourseServiceImpl().searchAllCourse();
            this.courses=courses1;
            this.notify();
        }

    }

    @Override
    public synchronized List<Course> getCourse() {

        List<Course> courses=null;
        if(getAllCourse()==0){
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }else{
            courses=this.courses;
            courses.remove(this.course);
            //System.out.println("选课完成-1");
            this.notify();

        }
        return courses;

    }
}*/
